Origin server hostname

What is origin server hostname

In the HTTP protocol, the Host header is a param sent by the client (such as a browser or CDN) to the server, used to identify the target domain name of the client's request. For example:

GET /index.html HTTP/1.1
Host: https://www.example.com #Host Head

The origin server determines which domain name the client is requesting based on the Host header and returns the corresponding content (especially in scenarios where multiple domains share the same server IP).

The function of origin server hostname

Ensure that the origin correctly parses the request

If the origin distinguishes different websites (virtual hosts) through the Host header, an incorrect Host header will cause the origin to return 404 or default content.
● Case:
The origin hosted origin.example.com, but when the CDN returned to the origin, the Host header was cdn.example.com → The origin returned an error because it could not recognize the domain name.

Match SSL certificate

● If HTTPS is enabled on the origin, the SSL certificate must match the domain name in the Host header, otherwise a certificate error will be triggered.
● Case:
The origin certificate is only bound to origin.example.com, but the origin server host header is cdn.example.com → HTTPS handshake failed.

Support origin security policies

The origin may filter requests through Host headers (such as firewall rules or whitelists), and incorrect Host headers will be rejected.
● Case:
The origin only allows requests with Host header origin.example.com → If CDN does not configure this value, returning to the origin will fail.

Adapt to special origin architecture

Some origins( such as object storage and API gateways) require a fixed Host header to properly handle requests.
● Case:
Some OSS service providers require the orgin Host header to be a bucket domain name (such as bucket.oss-cn-beijing. aliyuncs.com).

Rules of Origin server hostname for LightCDN

When CDN returns to the source, there are usually three modes for handling the Host header:

Follow CDN hostname (default)

● Behavior: CDN sends the hostname requested by the user directly as the Host header to the origin.
Example:
○ When the user requests CDN to return to the origin, the Host header is still cdn.example.com.
● Applicable scenarios:
○ The origin has been configured to accept CDN hostnames( such as reverse proxies or wildcard certificates).
○ The origin is consistent with the CDN hostname( such as direct hosting services on the source site).
○ The origin needs to verify the legality of the Host header (such as url signing). The url signing requires the Host header to ensure consistency with a legitimate domain name.

Follow origin

● Behavior: When CDN returns to the origin, forcibly modify the Host header to the specified origin or origin IP.
Example:
When the user requests cdn.example.com → CDN to return to the origin, the Host header is changed to origin.example.com.
●Applicable scenarios:
○ The origin is an IP address, without a virtual host, and responds directly to requests. At this point, there is no verification logic for the origin, making it easier to return the origin IP. This situation also applies to Follow CDN hostname.
○ The origin is a domain name, a virtual host, and needs to be routed to different sites or services based on the Host header( such as multi tenant architecture).

Customization

● Behavior: When LightCDN returns to the origin, force the Host header to be modified to the specified URL address.
Example:
When the user requests cdn.example.com → CDN to return to the origin, the Host header should be changed to bucket.oss-cn-beijing.aliyuncs. com(This is actually the return address you set for the origin).
● Applicable scenarios:
○ The origin distinguishes services through domain names( such as multi tenant architecture). This situation also applies to follow origin.
○ The CDN hostname is inconsistent with the origin( For example, the origin is a third-party service or object storage), relying on the Host header to identify the storage bucket or service. The OSS service providers require that the Host header must be a bucket domain name, and the Host header must be a domain name bound to the origin. This situation can also apply to Follow CDN hostname.

Configuration suggestions

Single origin: If the CDN hostname is the same as the origin, please select the Follow CDN hostname; If they are inconsistent, please select the Follow origin.
Multi origins: Configure the corresponding Host header for each origin separately, which is not performed on LightCDN.

How to configure the origin server hostname on LightCDN

You can go to RulesOrigin rules and select Origin server hostname.

Verification method

Capture packet test

curl -v -H "Host: cdn.example.com" http://Origin IP

View origin logs

Check if the Host header in the request received by the origin meets expectations.

Summary

The origin server hostname is the "bridge" connecting CDN and the origin, which directly affects whether the return request can be processed correctly. Reasonably configuring the Host header can avoid issues such as 404 errors and certificate verification failures, and is one of the key factors for CDN acceleration stability.

LightCDN all right reserved,powered by GitbookUpdated Time: 2025-03-06 11:47:58

results matching ""

    No results matching ""